﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace MeasurementTools
{
	/// <summary>
	/// Interaction logic for PositionPreview.xaml
	/// </summary>
	public partial class PositionPreview : UserControl
	{
        Point m_imageSize;
        Point m_imagePos;
        Point m_circlePos;

		public PositionPreview()
		{
			this.InitializeComponent();
		}

        public Point ImageSize
        {
            get { return m_imageSize; }
            set
            {
                m_imageSize = value;
                main_grid.Height = 60 * m_imageSize.Y / m_imageSize.X;
                main_grid.UpdateLayout();
            }
        }

        public Point ImagePos
        {
            get { return m_imagePos; }
            set
            {
                m_imagePos = value;
            }
        }

        public Point CirclePos
        {
            get { return m_circlePos; }
            set
            {
                if (value.X <= 0 || value.Y <= 0)
                    return;

                m_circlePos = value;
                circle.Margin = new Thickness(main_grid.ActualWidth * m_circlePos.X / m_imageSize.X - circle.ActualWidth / 2.0,
                                              main_grid.ActualHeight * m_circlePos.Y / m_imageSize.Y - circle.ActualHeight / 2.0, 0, 0);
                line_hor.Margin = new Thickness(0, main_grid.ActualHeight * m_circlePos.Y / m_imageSize.Y, 0, 0);
                line_ver.Margin = new Thickness(main_grid.ActualWidth * m_circlePos.X / m_imageSize.X, 0, 0, 0);

                System.Console.WriteLine("image size {0},{1}", m_imageSize.X, m_imageSize.Y);
                System.Console.WriteLine("circle pos {0},{1}", m_circlePos.X, m_circlePos.Y);
            }
        }
	}
}